package com.xmut.mapper;

import com.xmut.pojo.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface UserMapper {
    @Insert("insert into user(username,telphone,password,isadmin) values (#{username},#{telphone},#{password},#{isadmin})")
    void rigister(User user);

    @Select("select * from user")
    List<User> getAllUser();

    @Select("select * from user where username = #{username}")
    User getUserByName(String username);

    @Select("select * from user where id = #{id}")
    User getVolunteerInfo(Integer id);

    @Update("update user set organization = #{organization} , contracaddress = #{contracaddress} where id = #{id}")
    void insVolunteerAddress(User user);

    @Update("update user set isvolunteer = 1 where id = #{id}")
    void setVolunteer(Integer id);
}
